package com.xindacloud.sms.adapter.utils;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class NexmoStatusHelp {

    public enum NumberInsightStatus {
        MISSING_PARAMS(3, "您的请求不完整,缺少一些必填参数"),
        INVALID_CREDENTIALS(4, "无效的凭据-您提供的凭证无效或已被禁用"),
        INVALID_PARAMS(5, "内部错误-收件人地址的格式无效"),
        INSUFFICIENT_BALANCE(9, "超出配额-您的帐户没有足够的信用额度来处理此请求"),
        UNKNOWN(9999, "未知异常");

        private int code;
        private String message;

        private static final Map<Integer, NumberInsightStatus> MESSAGE_STATUS_INDEX = new HashMap<>();

        static {
            for (NumberInsightStatus status : NumberInsightStatus.values()) {
                MESSAGE_STATUS_INDEX.put(status.code, status);
            }
        }

        NumberInsightStatus(int code, String message) {
            this.code = code;
            this.message = message;
        }

        @JsonCreator
        public static NumberInsightStatus fromInt(int code) {
            NumberInsightStatus foundStatus = MESSAGE_STATUS_INDEX.get(code);
            return (foundStatus != null) ? foundStatus : UNKNOWN;
        }

        public int getCode() {
            return code;
        }

        public NumberInsightStatus setCode(int code) {
            this.code = code;
            return this;
        }

        public String getMessage() {
            return message;
        }

        public NumberInsightStatus setMessage(String message) {
            this.message = message;
            return this;
        }
    }


}
